package gold.digger;

import java.util.*;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC406 {
    public long startExecuteTime = System.currentTimeMillis();

    /*
        * @param 此题目参考了别人代码
        * 这是因为问题情况较为复杂
        * 未来需要再次复习此道题目
        * @return:
        */
    class Solution {
        public int[][] reconstructQueue(int[][] people) {
            Arrays.sort(people, new Comparator<int[]>() {
                @Override
                public int compare(int[] o1, int[] o2) {
                    // if the heights are equal, compare k-values
                    return o1[0] == o2[0] ? o1[1] - o2[1] : o2[0] - o1[0];
                }
            });

            List<int[]> output = new LinkedList<>();
            for (int[] p : people) {
                output.add(p[1], p);
            }

            int n = people.length;
            return output.toArray(new int[n][2]);
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC406 an = new LC406();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
